package com.alili_tv.system.service.impl;

import com.alili_tv.system.entity.Follow;
import com.alili_tv.system.mapper.FollowMapper;
import com.alili_tv.system.service.FollowService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户关注表 服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2023-03-17
 */
@Service
public class FollowServiceImpl extends ServiceImpl<FollowMapper, Follow> implements FollowService {

    @Override
    public boolean isFollow(long userId, long uploaderId) {
        LambdaQueryWrapper<Follow> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper
                .eq(Follow::getCreateUser, userId)
                .eq(Follow::getUploader, uploaderId);
        return this.count(queryWrapper) != 0;
    }
}
